package com.stefan.lession05;

import javax.swing.*;
import java.awt.*;

public class MyJPanel extends JFrame {

    public MyJPanel(){
        Container container = this.getContentPane();
        container.setLayout(new GridLayout(2,1,10,10));// 后面参数是间距

        JPanel jPanel1 = new JPanel(new GridLayout(1,3));
        JPanel jPanel2 = new JPanel(new GridLayout(2,1));
        JPanel jPanel3 = new JPanel(new GridLayout(1,2));

        jPanel1.add(new JButton("1"));
        jPanel1.add(new JButton("2"));
        jPanel1.add(new JButton("3"));
        jPanel2.add(new JButton("4"));
        jPanel2.add(new JButton("5"));
        jPanel3.add(new JButton("6"));
        jPanel3.add(new JButton("7"));

        container.add(jPanel1);
        container.add(jPanel2);
        container.add(jPanel3);

        this.setVisible(true);
        this.setSize(500,500);
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    }

    public static void main(String[] args) {
        new MyJPanel();
    }
}
